from llama_index.core.vector_stores import SimpleVectorStore
from llama_index.core.schema import  TextNode
from llama_index.core import Settings
from llama_index.embeddings.zhipuai import ZhipuAIEmbedding

embed_model = ZhipuAIEmbedding(
    model="embedding-2",
    api_key="f387f5e4837d4e4bba6d267682a957c9.PmPiTw8qVlsI2Oi5"
    # With the `embedding-3` class
    # of models, you can specify the size
    # of the embeddings you want returned.
    # dimensions=1024
)
Settings.embed_model=embed_model

text="""金秋十月，中华人民共和国迎来76周年华诞。每逢国庆，无论身处何地，爱国主义情愫都会引发中华儿女心中的共鸣。
爱国，是人世间最深层、最持久的情感，是每一个中国人的心之所系、情之所归。"""

store = SimpleVectorStore()
node = TextNode(text=text, metadata={"title": "金秋十月"})
node.embedding=embed_model.get_text_embedding(text)

store.add(  [node]  )

store.persist()
